<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="Content-Language" content="zh-cn" />
	<title>View Files</title>
</head>
<body>
<div>
   <TABLE height=110 cellSpacing=0 cellPadding=0 width=1000 align=center border=0>
      <TR>
        <TD background=./images/logo.jpg height=206>
        </TD></TR></TABLE>
	</div>
<div>
<?php // display the files uploaded to the server
 $page_title='View Files';
 require('db.php');
 
 $first=TRUE;
 
 $query="SELECT upload_id, file_name, ROUND(file_size/1024) AS fs, description,
		DATE_FORMAT(date_entered, '%M %e, %Y') AS d FROM uploads ORDER BY date_entered DESC";
 $result=mysql_query($query);
 
 //display
 while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
	if ($first) {
		echo '<table border="0" width="1000" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td align="left" width="200><font size="+1">文件名字</font></td>
					<td align="left" width=500><font size="+1">文件描述</font></td>
					<td align="center" width=100><font size="+1">文件大小</font></td>
					<td align="center" width=150><font size="+1">上传时间</font></td>
					<td align=right" width=50><font size="+1"></font></td>
				</tr>';
		$first = FALSE;
	}
	
	echo " <tr>
				<td align=\"left\"><a href=\"download_file.php?f_id={$row['upload_id']}\">{$row['file_name']}</a></td>
				<td align=\"left\">{$row['description']}</td>
				<td align=\"center\">{$row['fs']}kb</td>
				<td align=\"center\">{$row['d']}</td>
				<td align=\"right\"><a href=\"delete_file.php?f_id={$row['upload_id']}\" onclick=\"return confirm('删除后无法恢复,确定要删除吗')\">删除</a></td>
		   </tr>\n";
}

if ($first) {
	echo '<div align="center">--目前没有可用资料--</div>';
} else {
	echo '</table>';
}

mysql_close();
?>
</div>
&nbsp;
<div>
<table width=1000 align=center>
<form enctype="multipart/form-data" action="add_file.php" method="post">
	<div><fieldset><legend><b>-----------------------------------上传文件-----------------------------------</b></legend>
	<p><b>文件路径:</b><input type="file" name="upload" /></p>
	<p><b>文件描述:</b><textarea name="description" cols="40" rows='5'></textarea></p></fieldset></div>
	<input type="hidden" name="submitted" value="TRUE" />
	<div align="center"><input type="submit" name="submit" value="上传"></div>
</form>
</table>
</body>
</html>
